//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Diagram.Serialization;
using OpenLS.Drawing.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class ColorTransform : IOfficeXmlSerializable
    {
        List<CTName> _titles = new List<CTName>();
        List<CTDescription> descriptions = new List<CTDescription>();
        List<CTStyleLabel>_styleLbls = new List<CTStyleLabel>();
        private Categories _catLst;
        private OfficeArtExtensionList _extLst;
        private string _uniqueId;
        private string _minVer;

        public void ReadXml(ReadContext context)
        {

            using (var c = context.Read("colorsDef"))
            {

                _uniqueId = c.GetOptionalString("uniqueId", string.Empty);
                _minVer = c.GetOptionalString("minVer", DiagramConstants.DiagramNamespaceUri);
                _titles.Clear();
                _titles.AddRange(c.ReadOptionalWhile<CTName>("title"));
                descriptions.Clear();
                descriptions.AddRange(c.ReadOptionalWhile<CTDescription>(CTDescription.xmlName));
                _catLst = c.ReadOptionalElement<Categories>("catLst");
                _styleLbls.Clear();
                _styleLbls.AddRange(c.ReadOptionalWhile<CTStyleLabel>("styleLbl"));
                _extLst = c.ReadOptionalElement<OfficeArtExtensionList>("extLst");

            }
        }
        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("colorsDef"))
            {
                c.DeclareNamespace(DrawingConstants.DrawingNamespace);
                c.SetOptionalString("uniqueId", _uniqueId, string.Empty);
                c.SetOptionalString("minVer", _minVer, Diagram.Serialization.DiagramConstants.DiagramNamespaceUri);
                c.WriteElements(_titles);
                c.WriteElements(descriptions);
                c.WriteOptionalElement(_catLst);
                c.WriteElements(_styleLbls);
                c.WriteOptionalElement(_extLst);

            }

        }
    }
}